<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" ref="dataFormRef" @keyup.enter.native="getDataList()">
      <el-form-item>
        开方日期：
        <el-date-picker v-model="dataForm.queryDates" type="daterange" value-format="yyyy-MM-dd" range-separator="至"
          start-placeholder="开始日期" end-placeholder="结束日期" size="mini" @blur="getDataList()" clearable>
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        审批状态：
        <el-select size="mini" v-model="dataForm.auditStatus" clearable placeholder="请选择" @change="getDataList()"
          @clear="getDataList()">
          <el-option value="1" label="审批通过"></el-option>
          <el-option value="0" label="未审批"></el-option>
          <el-option value="-1" label="不通过"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        主单过滤：
        <el-select size="mini" v-model="dataForm.queryField" clearable placeholder="请选择" @change="getDataList()"
          @clear="getDataList()">
          <el-option v-for="item in queryFields" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input size="mini" v-model="dataForm.key" placeholder="参数名" clearable @blur="getDataList()"
          @clear="getDataList()"></el-input>
      </el-form-item>

      <el-form-item>
        明细过滤：
        <el-select size="mini" v-model="dataForm.queryItemField" clearable placeholder="请选择" @change="getDataList()"
          @clear="getDataList()">
          <el-option v-for="item in queryItemFields" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-input size="mini" v-model="dataForm.itemKey" placeholder="参数名" clearable @blur="getDataList()"
          @clear="getDataList()"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button size="mini" type="success" @click="getDataList()" icon="el-icon-search">查询</el-button>
        <el-button @click="resetForm" size="mini" type="warning" icon="el-icon-refresh-left">重置</el-button>
      </el-form-item>
    </el-form>
    <div class="content-box">
      <div class="dialog-box">
        <el-form>
          <el-form-item>
            <el-button-group>
              <el-button size="mini" v-if="isAuth('sale:saleadjustprice:save')" type="primary" @click="addOrUpdateHandle()"
                icon="el-icon-plus">新增</el-button>
              <el-button size="mini" v-if="isAuth('sale:saleadjustprice:update')" type="primary" @click="addOrUpdateHandle()"
                icon="el-icon-edit" :disabled="dataListSelections.length <= 0">修改</el-button>
              <el-button size="mini" v-if="isAuth('sale:saleadjustprice:delete')" type="danger" @click="deleteHandle()"
                icon="el-icon-delete" :disabled="dataListSelections.length <= 0">删除</el-button>
             </el-button-group>

              <el-button size="mini" v-if="isAuth('sale:saleadjustprice:export')" type="green" @click="exportData"
                class="iconfont icon-topsales">导出</el-button>
             <el-button-group>
              <el-button size="mini" v-if="isAuth('sale:saleadjustprice:audit')" type="success" @click="showAuditDialog()"
                class="iconfont icon-shengyijing" :disabled="dataListSelections.length <= 0">审核
              </el-button>
              <el-button size="mini" v-if="isAuth('sale:saleadjustprice:audit')" type="success" @click="showAuditDialog()"
                class="iconfont icon-shengyijing" :disabled="dataListSelections.length <= 0">复核
              </el-button>
              </el-button-group>
              <el-button size="mini" v-if="isAuth('sale:saleadjustprice:export')" type="goon" @click="printRx"
                class="iconfont icon-print" :disabled="dataListSelections.length <= 0">打印</el-button>
          </el-form-item>
          <el-form-item>
            <el-dialog title="导入数据" :visible.sync="upload.open" width="400px" append-to-body :close-on-click-modal="false">
              <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
                :before-upload="beforeUpload" :action="upload.url" :disabled="upload.isUploading"
                :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false"
                :file-list="excelList" :on-remove="onRemoveDr" :on-change="onChangeDr" drag>
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">
                  将文件拖到此处，或
                  <em>点击上传</em>
                </div>
                <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
              </el-upload>
              <el-button size="mini" type="success" @click="downloadImportTemplate">下载模板</el-button>
              <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitFileForm">导 入</el-button>
                <el-button @click="cancelFileForm">取 消</el-button>
              </div>
            </el-dialog>
          </el-form-item>
        </el-form>
        <!-- 主表 -->
        <el-table :data="dataList" size="mini" v-loading="dataListLoading" @selection-change="selectionChangeHandle"
          style="width: 100%;" @cell-click="cellClick" @cell-dblclick="tableDbEdit" height="320"
          :header-cell-style="{ background: '#fcfcfc', color: '#606266', height:'36px'}">
          <el-table-column type="selection" header-align="center" align="center" width="50">
          </el-table-column>
          <el-table-column prop="prescriptionNo" header-align="center" align="center" label="处方单号" width="140" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-tag type="success" size="mini" @click="copyText(scope.row.prescriptionNo)" style="cursor: pointer;" >
                复制
              </el-tag>
              {{ scope.row.prescriptionNo}}
            </template>
          </el-table-column>
          <el-table-column prop="prescriptionDate" header-align="center" align="center" label="单据日期" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="prescriptionUnit" header-align="center" align="center" label="开方单位" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="prescriptionUser" header-align="center" align="center" label="开方人">
          </el-table-column>
         <!-- <el-table-column prop="prescriptionUrl" header-align="center" align="center" label="处方图片">
          </el-table-column> -->
          <el-table-column prop="buyerName" header-align="center" align="center" label="购买人">
          </el-table-column>
          <el-table-column prop="buyerMobile" header-align="center" align="center" label="购买人手机" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="buyerCardId" header-align="center" align="center" label="身份证号" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="auditor" header-align="center" align="center" label="审核人">
          </el-table-column>
          <el-table-column prop="auditStatus" header-align="center" align="center" label="审核状态">
            <template slot-scope="scope">
              <el-tag type="success" size="mini" v-if="scope.row.auditStatus == 1">审核通过</el-tag>
              <el-tag type="danger" size="mini" v-else-if="scope.row.auditStatus == -1">审核不通过</el-tag>
              <el-tag type="info" size="mini" v-else>未审核</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="reviewNote" header-align="center" align="center" label="审核说明" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="reviewer" header-align="center" align="center" label="复核人">
          </el-table-column>
          <el-table-column prop="reviewStatus" header-align="center" align="center" label="复核状态">
            <template slot-scope="scope">
              <el-tag type="success" size="mini" v-if="scope.row.reviewStatus == 1">复核通过</el-tag>
              <el-tag type="danger" size="mini" v-else-if="scope.row.reviewStatus == -1">复核不通过</el-tag>
              <el-tag type="info" size="mini" v-else>未复核</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="reviewNote" header-align="center" align="center" label="复核说明" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="certificateType" header-align="center" align="center" label="证件类型">
          </el-table-column>
          <el-table-column prop="recipeSerialNum" header-align="center" align="center" label="处方序列号" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="prescriptionType" header-align="center" align="center" label="处方类型">
            <template slot-scope="scope">
              <el-tag type="success" size="mini" v-if="scope.row.prescriptionType == 1">西药处方</el-tag>
              <el-tag type="primary" size="mini" v-else-if="scope.row.prescriptionType == 2">中药处方</el-tag>
              <el-tag type="info" size="mini" v-else>普通处方</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="isRemoteAudit" header-align="center" align="center" label="远程审方">
            <template slot-scope="scope">
              <el-tag type="success" size="mini" v-if="scope.row.isRemoteAudit == 1">是</el-tag>
              <el-tag type="info" size="mini" v-else>否</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="isCompleteLater" header-align="center" align="center" label="是否后补">
            <template slot-scope="scope">
              <el-tag type="success" size="mini" v-if="scope.row.isCompleteLater == 1">是</el-tag>
              <el-tag type="info" size="mini" v-else>否</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="sendState" header-align="center" align="center" label="发送状态">
            <template slot-scope="scope">
              <el-tag type="success" size="mini" v-if="scope.row.sendState == 1">已发送</el-tag>
              <el-tag type="info" size="mini" v-else>未发送</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="address" header-align="center" align="center" label="地址" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="age" header-align="center" align="center" label="年龄">
          </el-table-column>
          <el-table-column prop="gender" header-align="center" align="center" label="性别">
            <template slot-scope="scope">
              <el-tag type="success" size="mini" v-if="scope.row.gender == 1">男</el-tag>
              <el-tag type="info" size="mini" v-else>女</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="birthday" header-align="center" align="center" label="生日">
          </el-table-column>
          <el-table-column prop="patientDiseases" header-align="center" align="center" label="确诊疾病" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="icdCode" header-align="center" align="center" label="ICD编码" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="icdName" header-align="center" align="center" label="ICD名称" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="guoMinDetail" header-align="center" align="center" label="过敏史" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="firstPrescriptionUrl" header-align="center" align="center" label="首诊处方单" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="medicalHistory" header-align="center" align="center" label="历史病例" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="cihuaStatus" header-align="center" align="center" label="慈桦处方状态" width="140" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-tag type="success" size="mini" v-if="scope.row.cihuaStatus == 1">成功</el-tag>
              <el-tag type="warning" size="mini" v-if="scope.row.cihuaStatus == 2">审核中</el-tag>
              <el-tag type="info" size="mini" v-else>未发送</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="prescriptionDosis" header-align="center" align="center" label="处方剂数">
          </el-table-column>
          <el-table-column prop="usingType" header-align="center" align="center" label="煎服法" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="prescriptionUsage" header-align="center" align="center" label="方剂用法" width="140" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="storeName" header-align="center" align="center" label="门店名称" v-if="hasRole('role:sys:super:admin')">
          </el-table-column>
          <el-table-column prop="storeCode" header-align="center" align="center" label="门店编码" v-if="hasRole('role:sys:super:admin')">
          </el-table-column>
          <el-table-column prop="updateTime" header-align="center" align="center" label="修改时间">
            <template slot-scope="scope">
            </template>
          </el-table-column>
          <el-table-column prop="updateUsername" header-align="center" align="center" label="修改人">
            <template slot-scope="scope">
            </template>
          </el-table-column>
          <el-table-column prop="remark" header-align="center" align="center" label="备注">
            <template slot-scope="scope">
              <span v-html="scope.row.remark"></span>
            </template>
          </el-table-column>
        </el-table>

        <!-- 子表 -->
         <el-table :data="itemDataList" size="mini" v-loading="dataListLoading" @selection-change="selectionChangeHandle"
           style="width: 100%;" class="item-table" height="250"
           :header-cell-style="{ background: '#fcfcfc', color: '#606266', height:'36px'}">
           <el-table-column prop="productCode" header-align="center" align="center" label="产品编号" width="140" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-tag type="success" size="mini" @click="copyText(scope.row.productCode)" style="cursor: pointer;" >
                复制
              </el-tag>
              {{ scope.row.productCode}}
            </template>
           </el-table-column>
           <el-table-column prop="productName" header-align="center" align="center" label="产品名称" width="140" show-overflow-tooltip>
              <template slot-scope="scope">
                <el-tag type="success" size="mini" @click="copyText(scope.row.productName)" style="cursor: pointer;" >
                  复制
                </el-tag>
                {{ scope.row.productName}}
              </template>
           </el-table-column>
           <el-table-column prop="genericName" header-align="center" align="center" label="通用名" width="140" show-overflow-tooltip>
           </el-table-column>
           <el-table-column prop="standard" header-align="center" align="center" label="规格" width="140" show-overflow-tooltip>
           </el-table-column>
           <el-table-column prop="unit" header-align="center" align="center" label="单位">
           </el-table-column>
           <el-table-column prop="approvalNo" header-align="center" align="center" label="批准文号" width="140" show-overflow-tooltip>
           </el-table-column>
           <el-table-column prop="producingArea" header-align="center" align="center" label="产地" width="140" show-overflow-tooltip>
           </el-table-column>
           <el-table-column prop="produceFactory" header-align="center" align="center" label="生产单位" width="140" show-overflow-tooltip>
           </el-table-column>
           <el-table-column prop="dosageForm" header-align="center" align="center" label="剂型" width="140" show-overflow-tooltip>
           </el-table-column>
           <el-table-column prop="buyNum" header-align="center" align="center" label="购买数量">
           </el-table-column>
           <el-table-column prop="price" header-align="center" align="center" label="价格">
           </el-table-column>
           <el-table-column prop="totalFee" header-align="center" align="center" label="金额">
           </el-table-column>
           <el-table-column prop="useMethod" header-align="center" align="center" label="使用方法" width="140" show-overflow-tooltip>
           </el-table-column>
           <el-table-column prop="useFrequencyUnit" header-align="center" align="center" label="频率周期">
           </el-table-column>
           <el-table-column prop="useFrequencyNum" header-align="center" align="center" label="频率数量">
           </el-table-column>
           <el-table-column prop="usePerUseNum" header-align="center" align="center" label="每次用药数量" width="140" show-overflow-tooltip>
           </el-table-column>
           <el-table-column prop="usePerUseUnit" header-align="center" align="center" label="每次用药单位" width="140" show-overflow-tooltip>
           </el-table-column>
           <el-table-column prop="useDays" header-align="center" align="center" label="天数">
           </el-table-column>
           <el-table-column prop="updateTime" header-align="center" align="center" label="修改时间">
           </el-table-column>
           <el-table-column prop="updateUsername" header-align="center" align="center" label="修改人">
           </el-table-column>
           <el-table-column prop="remark" header-align="center" align="center" label="备注" width="140" show-overflow-tooltip>
             <template slot-scope="scope">
               <span v-html="scope.row.remark"></span>
             </template>
           </el-table-column>
         </el-table>

        <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
          :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
          layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>

      </div>

      <div class="rx-pic-box">
        <img />
      </div>
    </div>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <!-- 审核 -->
    <dialog-audit v-if="auditVisible" ref="dialogAudit"></dialog-audit>
  </div>
</template>

<script>
  import DialogAudit from '@/views/components/dialog-audit'
  import AddOrUpdate from './saleprescriptionorder-add-or-update'
  import {downLoadFile,hasRole} from '@/utils/myUtil.js'
  import {Loading} from "element-ui"
  export default {
    data() {
      return {
        dataForm: {
          queryDates:[],
          isAudit: undefined,
          key: '',
          queryField: '',
          itemKey: '',
          queryItemField: '',
        },
        dusers: [],
        queryFields: [],
        queryItemFields: [],
        dataList: [],
        itemDataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false,
        auditVisible: false,
        showInput: "",
        oldData: {},
        currentData: {},
        showItemInput: "",
        oldItemData: {},
        currentItemData: {},
        auditVisible: false,
        //导入
        upload: {
          // 是否显示弹出层（用户导入）
          open: false,
          // 弹出层标题（用户导入）
          title: "导入药品数据",
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          // updateSupport: 0,
          // 设置上传的请求头部
          // 上传的地址
          url: `${window.SITE_CONFIG.baseUrl}/sale/saleprescriptionorder/importData`
        },
        //上传的文件
        excelList: [],
      }
    },
    components: {
      AddOrUpdate,
      DialogAudit
    },
    activated() {
      this.getDataList()
      this.initQueryParams()
    },
    methods: {
      // 获取数据列表
      async getDataList() {
        this.itemDataList = []
        this.dataListLoading = true
        let newDataForm = _.cloneDeep(this.dataForm)
        let queryDates = newDataForm.queryDates || [];
        newDataForm.queryDates = queryDates.join(",")
        const res = await this.$http({
          url: `/sale/saleprescriptionorder/page`,
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'dataForm': newDataForm
          })
        })
        let data = res.data
        if (data && data.code === 0) {
          this.dataList = data.page.list
          this.totalPage = data.page.totalCount
          this.dataList.forEach(item => {
            item.status = item.status == 1 ? true : false
          })
          if (this.dataList.length > 0) {
            this.getItemDataList(this.dataList[0].prescriptionId)
          }else{
            this.itemDataList = []
          }
        } else {
          this.dataList = []
          this.totalPage = 0
        }
        this.dataListLoading = false
      },
      async getItemDataList(prescriptionId) {
        const res = await this.$http({
          url: `/sale/saleprescriptionorder/listByOrderId`,
          method: 'get',
          params: this.$http.adornParams({
            prescriptionId
          })
        })
        let data = res.data
        if (data && data.code === 0) {
          this.itemDataList = data.list
        } else {
          this.itemDataList = []
        }
      },
      // 每页数
      sizeChangeHandle(val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle(val) {
        this.dataListSelections = val
      },
      // 新增 / 修改
      addOrUpdateHandle(id) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      // 删除
      deleteHandle(id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.prescriptionId
        })
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          const res = await this.$http({
            url: `/sale/saleprescriptionorder/delete`,
            method: 'delete',
            data: this.$http.adornData(ids, false)
          })
          let data = res.data
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.getDataList()
              }
            })
          } else {
            this.$message.error(data.msg)
          }
        })
      },
      resetForm() {
        this.$nextTick(() => {
          this.dataForm = this.$options.data().dataForm
          this.getDataList()
        })
      },
      async saveHandle(row) {
        row.status = row.status ? 1 : 0
        const res = await this.$http({
          url: `/sale/saleprescriptionorder/update`,
          method: 'post',
          data: this.$http.adornData(row)
        });
        let data = res.data
        if (data && data.code !== 0) {
          row.status = !row.status;
          return this.$message.error('修改失败!');
        }
        this.$message.success('更新成功！');
        this.getDataList();
      },
      // 当input失去光标后进行的操作
      async blurInput(row, name, value) {
        // 判断数据是否有所改变，如果数据有改变则调用修改接口
        if (this.oldData[name] != value) {
          row[name] = value
          if (value === true) {
            row[name] = 1
          } else if (value === false) {
            row[name] = 0
          }
        }
        this.showInput = ""
        this.currentData = row
      },
      tableDbEdit(row, column, event) {
        this.showInput = column.property + row.prescriptionId;
        this.oldData[column.property] = row[column.property];
      },
      printRx(){

      },
      cellClick(row, column, event){
        this.getItemDataList(row.prescriptionId)
      },
      async blurItemInput(row, name, value) {
        // 判断数据是否有所改变，如果数据有改变则调用修改接口
        if (this.oldItemData[name] != value) {
          row[name] = value
          if (value === true) {
            row[name] = 1
          } else if (value === false) {
            row[name] = 0
          }
        }
        this.showItemInput = ""
        this.currentItemData = row
      },
      itemTableDbEdit(row, column, event){
        this.showItemInput = column.property + row.detailId;
        this.oldItemData[column.property] = row[column.property];
      },
      async saveItemHandle(row) {
        row.status = row.status ? 1 : 0
        const res = await this.$http({
          url: `/sale/saleprescriptionorderdetail/update`,
          method: 'post',
          data: this.$http.adornData(row)
        });
        let data = res.data
        if (data && data.code !== 0) {
          row.status = !row.status;
          return this.$message.error('修改失败!');
        }
        this.$message.success('更新成功！');
        this.getDataList();
      },
      deleteItemHandle(row) {
        let id = row.detailId
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.detailId
        })
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          const res = await this.$http({
            url: `/sale/saleprescriptionorderdetail/delete`,
            method: 'delete',
            data: this.$http.adornData(ids, false)
          })
          let data = res.data
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.getDataList();
              }
            })
          } else {
            this.$message.error(data.msg)
          }
        })
      },
      async exportData() {
        const res = await this.$http({
          url: `/sale/saleprescriptionorder/exportData`,
          method: 'get',
          responseType: 'blob',
          params: this.$http.adornParams()
        });
        downLoadFile(res)
      },
      beforeUpload(file) {
        //截取文件后缀名
        const fileName = file.name.substring(file.name.lastIndexOf('.'));
        if (fileName.toLowerCase() != '.xls' && fileName.toLowerCase() != '.xlsx') {
          this.$message.error('文件必须为.xls或xlsx类型');
          this.fileList = [];
          return false;
        };
        //读取文件大小
        var fileSize = file.size;
        if (fileSize > 3249576) {
          this.uploadShowDialog = false;
          this.$message({
            type: 'error',
            showClose: true,
            duration: 3000,
            message: '文件不能大于3M!'
          });
          return false;
        }
      },
      // excel表上传
      handleUploadChange(file, fileList) {
        if (fileList.length > 0) {
          // 这一步，是展示最后一次选择的文件
          this.fileList = [fileList[fileList.length - 1]];
        }
      },
      //导入按钮
      handleImport() {
        this.upload.open = true;
      },
      //导入提交
      async submitFileForm() {
        if (this.excelList.length === 0) {
          this.$message.warning("请选择文件");
          return;
        }
        if (this.excelList.length > 1) {
          this.$message.warning("每次只能提交一个文件");
          return;
        }
        let formData = new FormData();
        this.excelList.forEach((item) => {
          formData.append("file", item.raw);
        });
        let loadingInstance = Loading.service({
          lock: true, //lock的修改符--默认是false
          text: "导入中", //显示在加载图标下方的加载文案
          spinner: "el-icon-loading", //自定义加载图标类名
          background: "rgba(0, 0, 0, 0.7)", //遮罩层颜色
          target: document.querySelector("#futureTransferDialog"), //loadin覆盖的dom元素节点
        });
        const res = await this.$http({
          url: this.upload.url,
          method: 'post',
          data: formData
        })
        let data = res.data
        if (data && data.code === 0) {
          loadingInstance.close();
          this.$message({
            type: "success",
            message: "导入成功!",
          });
          this.getDataList();
        }
        this.excelList = [];
        this.upload.open = false;
        loadingInstance.close();
        this.dataListLoading = false
      },
      //下载导入模板
      downloadImportTemplate() {
        window.location.href = "http://file.asdzy.com/upload/files/film/品牌模板.xlsx"
      },
      // 文件上传成功处理
      handleFileSuccess(response, file, fileList) {
        this.excelList = fileList;
      },
      // 文件上传中处理
      handleFileUploadProgress(event, file, fileList) {
        this.upload.isUploading = true;
      },
      onChangeDr(file, fileList) {
        this.excelList = fileList;
      },
      onRemoveDr(file, fileList) {
        this.excelList = fileList;
      },
      cancelFileForm() {
        this.upload.open = false
        this.excelList = [];
      },

    },

    directives: {
      // 通过自定义指令实现的表单自动获得光标的操作
      focus: {
        inserted: function(el) {
          if (el.tagName.toLocaleLowerCase() == "input") {
            el.focus()
          } else {
            if (el.getElementsByTagName("input")) {
              el.getElementsByTagName("input")[0].focus()
            }
          }
          el.focus()
        }
      },
      focusTextarea: {
        inserted: function(el) {
          if (el.tagName.toLocaleLowerCase() == "textarea") {
            el.focus()
          } else {
            if (el.getElementsByTagName("textarea")) {
              el.getElementsByTagName("textarea")[0].focus()
            }
          }
          el.focus()
        }
      }
    },
  }
</script>

<style lang="less" scoped>

  .content-box{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    .dialog-box{
       float: right;
       width: 78%;
    }
    .rx-pic-box{
      float: right;
      width: 20%;
      margin-right: 20px;
      border-radius: 10px;
      img{
        border-radius: 10px;
        height: 720px;
        width: 400px;
      }
    }
  }

</style>
